package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.MarketGoods;
import com.cskaoyan.bean.bo.WxGoodsListBO;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.vo.WxGoodsCategoryVO;
import com.cskaoyan.bean.vo.WxGoodsDetailVO;
import com.cskaoyan.bean.vo.WxGoodsListVO;
import com.cskaoyan.service.WxGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 商品详情
 * \* User: 余雨健
 * \* Date: 2022/10/14
 * \* Time: 19:37
 **/
@RestController
@RequestMapping("wx/goods")
public class WxGoodsController {
    @Autowired
    WxGoodsService wxGoodsService;

    /**
     *@首页商品总数
     *@author yuyujian
     *@Date 2022/10/15
     *@Time 14:28
     */
    @RequestMapping("count")
    public BaseRespVo<Integer> count(){
        int count = wxGoodsService.selectGoodsCount();
        return BaseRespVo.ok(count,"成功");
    }

    /**
     *@商品所属类目
     *@author yuyujian
     *@Date 2022/10/15
     *@Time 14:28
     */
    @RequestMapping("category")
    public BaseRespVo<WxGoodsCategoryVO> category(Integer id){
        WxGoodsCategoryVO wxGoodsCategoryVO = wxGoodsService.selectCategory(id);
        return BaseRespVo.ok(wxGoodsCategoryVO,"成功");
    }

    /**
     *@当前分类类目下的所有商品信息
     *@author yuyujian
     *@Date 2022/10/15
     *@Time 14:31
     */
    @RequestMapping("list")
    public BaseRespVo<WxGoodsListVO> list(WxGoodsListBO wxGoodsListBO){
        WxGoodsListVO wxGoodsListVO = wxGoodsService.selectGoodsList(wxGoodsListBO);
        return BaseRespVo.ok(wxGoodsListVO,"成功");
    }

    /**
     *@当前商品细节信息
     *@author yuyujian
     *@Date 2022/10/15
     *@Time 14:32
     */
    @RequestMapping("detail")
    public BaseRespVo<WxGoodsDetailVO> detail(Integer id){
        WxGoodsDetailVO wxGoodsDetailVO = wxGoodsService.returnGoodsDetail(id);
        return BaseRespVo.ok(wxGoodsDetailVO,"成功");
    }

    /**
     *@当前商品关联的其他商品信息
     *@author yuyujian
     *@Date 2022/10/15
     *@Time 14:32
     */
    @RequestMapping("related")
    public BaseRespVo<CommonData> related(Integer id){
        CommonData<MarketGoods> marketGoodsCommonData = wxGoodsService.selectGoodsRelated(id);
        return BaseRespVo.ok(marketGoodsCommonData,"成功");
    }
}
